<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Title</title>
  </head>
  <body>
    <div>
      <input type="text" placeholder="请输入数字" v-model="v1" />
      <input type="text" placeholder="请输入数字" v-model="v2" />
      <input type="button" value="+" @click="f(1)" />
      <input type="button" value="-" @click="f(2)" />
      <input type="button" value="*" @click="f(3)" />
      <input type="button" value="/" @click="f(4)" />
      <h1>结果: {{info}}</h1>
    </div>
  </body>
  <!-- 创建Vue对象 -->
  <script src="./js/vue.min.js"></script>
  <script>
    let v = new Vue({
      el: "body>div",
      data: {
        v1: "",
        v2: "",
        info: "",
      },
      methods: {
        f(x) {
          switch (x) {
            case 1:
              v.info = v.v1 * 1 + v.v2 * 1;
              break;
            case 2:
              v.info = v.v1 - v.v2;
              break;
            case 3:
              v.info = v.v1 * v.v2;
              break;
            case 4:
              v.info = v.v1 / v.v2;
              break;
          }
        },
      },
    });
  </script>
</html>
